<?php
require('../action/db.php');

function get_sub_brand_menu($db,$product_class,$product_brand)
{
   $rs = $db->Execute("select product_sub_brand from SPIDER_PRODUCT_BRAND where product_class='".$product_class."' and product_brand='".$product_brand."'");
   $r  = "<select>";
   foreach($rs->getRows() as $k => $v)
   {
	 $r =$r."<option value=\"".$v['product_sub_brand']."\">".$v['product_sub_brand']."</option>";
   }
   $r = $r."</select>";
   return $r;
}

function get_brand_menu($db,$product_class)
{
  $result = Array();
  $rs= $db->Execute("select product_brand from SPIDER_PRODUCT_BRAND where product_class='".$product_class."' group by product_brand"); 
  $r = "<select>";
  $k = 0;
  $first_brand = "";
  foreach ($rs->getRows() as $k => $v)
  {
        $r =$r."<option value=\"".$v['product_brand']."\">".$v['product_brand']."</option>";
        if ($k == 0){
		$first_brand = $v['product_brand'];
		$k=1;
        }
  }
  $r = $r."</select>";
  $result[] = $r;
  $result[] = $first_brand;
  return $result;

}
/*
  require('../action/db.php');
  $rs= $db->Execute("select * from SPIDER_PRODUCT_BRAND where product_class='".$_GET["q"]."' group by product_brand"); 
  $r = "<form><select>";
  foreach ($rs->getRows() as $k => $v)
  {
        $r =$r."<option value=\"".$v['product_brand']."\">".$v['product_brand']."</option>";
  }
  $r = $r."</select></form>";*/
//  echo get_brand_menu($db,$_GET["q"]);
//  $a  =  get_brand_menu($db,$_GET["q"]);
//  $b  = get_sub_brand_menu($db,$_GET["q"],$a[1]);
//  echo "<form>".$a[0].$b."</form>"
?>
